﻿

using Knlght.Domain;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Knight.Models.Entity
{
    public class LogInfo:TEntityBase
    {
        public int Id { get; set; }
        public DateTime? AddTime { get; set; }
        public string Account { get; set; }
        public string Username { get; set; }
        public string TypeName { get; set; }
        public string IPAddress { get; set; }
        public string ModuleId { get; set; }
        public string ModuleName { get; set; }
        public bool? Result { get; set; }
        public string Description { get; set; }
        public string CreatorUserId { get; set; }
    }

    public enum DbLogType
    {
        /// <summary>
        /// 其他
        /// </summary>
        [Description("其他")]
        Other = 0,
        /// <summary>
        /// 登录
        /// </summary>
        [Description("系统登录")]
        Login = 1,
        /// <summary>
        /// 退出
        /// </summary>
        [Description("退出登录")]
        Exit = 2,
        /// <summary>
        /// 访问
        /// </summary>
        [Description("访问")]
        Visit = 3,
        /// <summary>
        /// 新增
        /// </summary>
        [Description("新增")]
        Create = 4,
        /// <summary>
        /// 删除
        /// </summary>
        [Description("删除")]
        Delete = 5,
        /// <summary>
        /// 修改
        /// </summary>
        [Description("修改")]
        Update = 6,
        /// <summary>
        /// 提交
        /// </summary>
        [Description("提交")]
        Submit = 7,
        /// <summary>
        /// 异常
        /// </summary>
        [Description("异常")]
        Exception = 8,
    }

    public class LogInfoMapping : EntityTypeConfiguration<LogInfo>
    {
        public LogInfoMapping()
        {
            // 设置表名
            this.ToTable("T" + nameof(LogInfo));
            //设置主键
            this.HasKey(a => a.Id);
            //不更新
            this.Property(t => t.AddTime).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);
            // 设置属性的类型和长度
            this.Property(a => a.Description).HasColumnType("NVarchar").HasMaxLength(1000);
            // this.Property(a => a.Account).HasColumnName("F" + nameof(LogInfo.Account));
        }
    }
}
